package demo14;

/**
 * Created by Administrator on 2017/6/20.
 */
class Quadrangle3{
    public static void draw(Quadrangle3 q){}
}
class Square extends Quadrangle3{}
class Anything{}
public class Parallelogram3 extends Quadrangle3{
    public static void main(String[] args) {
        Quadrangle3 q=new Quadrangle3();//实例化父类对象
        if(q instanceof Parallelogram3){//判断父类对象是否为Parallelogram子类的一个实例
            Parallelogram3 p=(Parallelogram3)q;//向下转型操作
        }
        if(q instanceof Square){//判断父类对象是否为Square子类的一个实例
            Square s=(Square)q;//进行向下转型操作
        }
        //System.out.println(q instanceof Anything);
    }
}
